package com.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.model.Emp;
import com.model.ResumeWorkExperience;
import com.service.EmpService;
import com.service.ResumeWorkExperienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 简历-工作经历表 前端控制器
 * </p>
 *
 * @author Damon
 * @since 2021-04-27
 */
@RestController
@RequestMapping("/resume-work-experience")
public class ResumeWorkExperienceController {


    //  列表数据  支持分页和条件查询
    @Autowired
    private ResumeWorkExperienceService resumeWorkExperienceService;
    //列表数据
    @RequestMapping("/worklist")
    public Page<ResumeWorkExperience> list(String resumeid,Long pageNum, Long size){
        //分页对象
        QueryWrapper<ResumeWorkExperience> sql = new QueryWrapper<ResumeWorkExperience>();
//        sql.like("resumeid",enameS);
        Page<ResumeWorkExperience> page = new Page<ResumeWorkExperience>(pageNum, size);
        page = resumeWorkExperienceService.listPage(page);
        return page;
    }

    //列表数据
    @RequestMapping("/worklistAll")
    public List<ResumeWorkExperience> worklistAll(){
        List<ResumeWorkExperience> worklist = resumeWorkExperienceService.list();
        return worklist;
    }

    //新增和修改
    @RequestMapping("/editwork")
    public boolean edit(@RequestBody ResumeWorkExperience resumeWorkExperience){
        boolean rmw = false;
        resumeWorkExperience.setUpdateDate(LocalDateTime.now());
        resumeWorkExperience.setCreateDate(LocalDateTime.now());
//        resumeWorkExperience.setStartDate();
        if("0".equals(resumeWorkExperience.getModify())){
            //新增
            rmw =resumeWorkExperienceService.save(resumeWorkExperience);
        }else{
            //修改
            rmw = resumeWorkExperienceService.updateById(resumeWorkExperience);
        }
        return rmw;
    }

    @RequestMapping("/getByworkid")
    public ResumeWorkExperience getByworkid(String id){
        return resumeWorkExperienceService.getById(id);
    }

    @RequestMapping("/del")
    public boolean del(ResumeWorkExperience resumeWorkExperience){
        return resumeWorkExperienceService.removeById(resumeWorkExperience.getId());
    }
}

